/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package outils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JOptionPane;


/**
 *
 * @author T.Ron
 */
public class Outils {
    
     public static void ouvrirJframe(JFrame fenetre){
         fenetre.setVisible(true);
     }
     
     public static String[] ListeDate() throws ParseException{
        List<Date> dates = new ArrayList<Date>();

        String str_date ="01/01/2010";
        String end_date ="31/12/2016";

        DateFormat formatter ; 

        formatter = new SimpleDateFormat("dd/MM/yyyy");
        Date  startDate = (Date)formatter.parse(str_date); 
        Date  endDate = (Date)formatter.parse(end_date);
        long interval = 24*1000 * 60 * 60; // 1 hour in millis
        long endTime =endDate.getTime() ; // create your endtime here, possibly using Calendar or Date
        long curTime = startDate.getTime();
        while (curTime <= endTime) {
            dates.add(new Date(curTime));
            curTime += interval;
        }
        
        String[] liste = new String[dates.size()+1];
        for(int i=0;i<dates.size();i++){
                Date lDate =(Date)dates.get(i);
                String ds = formatter.format(lDate);
                liste[i] =ds;
            }
        return liste;
     }
      
////     public static void supprElement(JList jList1){
////              if(!jList1.isSelectionEmpty()){
////            TaxeJpaController cjc = new TaxeJpaController ();
////            try {
////                if(JOptionPane.showConfirmDialog(this,
////                        "Voulez vous vraiment supprimer "+jList1.getSelectedValue()+" ?",
////                        "Fermeture de l'application",
////                        JOptionPane.YES_NO_OPTION)==0){
////                    cjc.destroy(Integer.parseInt(jList1.getSelectedValue().toString().split("-")[0].trim()));
////                }
////            } catch (NonexistentEntityException ex) {
////                Logger.getLogger(PlanJournal.class.getName()).log(Level.SEVERE, null, ex);
////            }
////        }
////     }
////     public static String[] listeNatureCompte(){
////        NaturecgJpaController ncg = new NaturecgJpaController();
////        List<Naturecg> lncg = ncg.findNaturecgEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getNumnaturecg()+" - "+lncg.get(i).getIntitulenaturecg();
////        }
////        return tncg;
////     }
////     
////     public static String[] listeTypeJournal(){
////        TypejoJpaController ncg = new TypejoJpaController();
////        List<Typejo> lncg = ncg.findTypejoEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getIdTypejo()+" - "+lncg.get(i).getLibelletypejo();
////        }
////        return tncg;
////     }
////     
////     public static String[] listeTaxe(){
////        TypetaxeJpaController ncg = new TypetaxeJpaController();
////        List<Typetaxe> lncg = ncg.findTypetaxeEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getIdTypetaxe()+" - "+lncg.get(i).getIntituletypetaxe();
////        }
////        return tncg;
////     }
////     
////     public static String[] listeSA(){
////        SectionanalJpaController ncg = new SectionanalJpaController();
////        List<Sectionanal> lncg = ncg.findSectionanalEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getIdSa()+" - "+lncg.get(i).getIntitulesa();
////        }
////        return tncg;
////     }
////     
////     public static String[] listeCT(){
////        TypectJpaController ncg = new TypectJpaController();
////        List<Typect> lncg = ncg.findTypectEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getNumtypect()+" - "+lncg.get(i).getIntituletypect();
////        }
////        return tncg;
////     }
////     
////     public static String[] listeCompteComptable(){
////        ComptegJpaController ncg = new ComptegJpaController();
////        List<Compteg> lncg = ncg.findComptegEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getIdCg()+" - "+lncg.get(i).getLibellecg();
////        }
////        return tncg;
////     }
////     
////     public static String[] listeCompteReporting(){
////        CompterJpaController ncr = new CompterJpaController();
////        List<Compter> lncg = ncr.findCompterEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getIdCr()+" - "+lncg.get(i).getIntitulecr();
////        }
////        return tncg;
////     }
////     
////     public static String[] listeCompteTiers(){
////        ComptetJpaController ncr = new ComptetJpaController();
////        List<Comptet> lncg = ncr.findComptetEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getIdCt()+" - "+lncg.get(i).getLibellect();
////        }
////        return tncg;
////     }
////     
////     public static String[] listeCompteAnalytique(){
////        CompteaJpaController ncr = new CompteaJpaController();
////        List<Comptea> lncg = ncr.findCompteaEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getIdCa()+" - "+lncg.get(i).getIntituleca();
////        }
////        return tncg;
////     }
////     
////     public static String[] listeJournaux(){
////        JournauxJpaController ncr = new JournauxJpaController();
////        List<Journaux> lncg = ncr.findJournauxEntities();
////        String[] tncg = new String[lncg.size()];
////        for(int i=0;i<lncg.size();i++){
////            tncg[i]= lncg.get(i).getNumjo()+" - "+lncg.get(i).getIntitulejo();
////        }
////        return tncg;
////     }
}
